import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: { infoList: [{ id: 1, msg: "这个是第一条信息哦~", status: false }] },
  mutations: {
    addList(state, msg) {
      if (msg) {
        state.infoList.push({ id: Date.now(), msg: msg, status: false });
      }
    },
    removeAddList(state, id) {
      var listIndex = state.infoList.findIndex((ele) => ele.id == id);
      state.infoList.splice(listIndex, 1);
    },
    overList(state, id) {
      state.infoList.find((ele) => ele.id == id).status = !state.infoList.find(
        (ele) => ele.id == id
      ).status;
    },
  },
});
export default store;
